<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/common/taglib.jsp" %>

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta content="微社区,Q生活" name="keywords"/>
<meta content="微社区,Q生活" name="description"/>
<title>微社区|Q生活</title>
<link rel="stylesheet" href="${ctx }/static/css/Master.css"/>
<link rel="stylesheet" href="${ctx }/static/css/lq.datetimepick.css"/>

<script src="${ctx }/static/js/jquery-1.9.0.min.js"></script>
<script src="${ctx }/static/js/simpletooltip.min.js"></script>
<script src="${ctx }/static/js/selectUi.js"></script>
<script src="${ctx}/static/plugins/My97DatePicker/WdatePicker.js"></script>

<script src="${ctx}/static/plugins/layer/layer.js"></script>
<%-- 基础js,所有页面都需要引入此js,依赖layer.js --%>
<script src="${ctx}/static/js/common/base.js"></script>
<script src="${ctx}/static/js/common/util.js"></script>
<script type="text/javascript">
$(function(){
	LQ.selectUi.show({id:"normal"});
});
//启用/停用
function doEnableOrDisable(id,normal,name){
	var msg = '确认'+(normal==1?'停用':'启用')+'"'+name+'"吗?';
	top.layer.confirm(msg, {icon: 3}, function(index){
		$.ajax({    
		    url:"${ctx}/role/"+id+"/"+normal+"/updateToEnableOrDisable",   
		    data:"",    
		    type:"get",    
		    cache:false,    
		    dataType:"json",
		    async:true, //默认为true 异步    
		    success:function(data) {
	            top.layer.msg(data,{},function(){
		        	window.location.reload();   
	            });
		     }  
		});
	});
}

//删除
function del(id,name) {
	top.layer.confirm('确认删除"'+name+'"吗?', {icon: 3}, function(index){
		$.ajax({    
		    url:"${ctx}/role/"+id+"/delete",   
		    data:"",    
		    type:"get",    
		    cache:false,    
		    dataType:"json",
		    async:true, //默认为true 异步    
		    success:function(data) {    
	            top.layer.msg(data,{},function(){
		        	window.location.reload();   
				});
		     } 
		});
	});
    
}
</script>
</head>

<body class="utilSubmit">
<section class="boxRight">
<form id="searchForm" method="get" >
<div class="context boxborder">

	<!-- 查询 -->
	<div class="SearchList">
		<ul class="clearfix">
			<li><span class="name">编号：</span><span class="pt"><input type="text" id="rolId" name="rolId" value="${result.entity.rolId }" class="utilInteger"/></span></li>
			<li><span class="name">角色名：</span><span class="pt"><input type="text" id="rolName" name="rolName" value="${result.entity.rolName }"/></span></li>
			<li><span class="name">状态： </span>
				<div id="normal" class="selectul" style="width: 85px;"><div class="selectfocus" data-value="${result.entity.normal}"><em></em></div><select>
				<option value="">请选择</option>
				<c:forEach items="${diy:getDicList('NORMAL') }" var="dic">
				<option value="${dic.code }">${dic.content }</option>
				</c:forEach>
				</select></div>
			</li>
			<li><span class="name">时间：</span><span class="date"><input type="text" placeholder="开始时间" id="dateStart" name="dateStart" value="${result.entity.dateStart }" onclick="WdatePicker({maxDate:'#F{$dp.$D(\'dateEnd\')}'})"/></span>
						<span class="fg">~</span><span class="date"><input type="text" placeholder="结束时间" id="dateEnd" name="dateEnd" value="${result.entity.dateEnd }" onclick="WdatePicker({minDate:'#F{$dp.$D(\'dateStart\')}'})"/></span></li>
			<li class="combtn pr"><a href="javascript:void(0);" onclick="submitPage(1,this);" class="utilSubmitBtn">查询</a><a href="javascript:void(0);" class="utilReset">重置</a> </li>
		</ul>
	</div>
	
	<!-- 顶部按钮 -->
	<shiro:hasPermission name="users:role:create">
	<div class="pr prlink"><a href="${ctx}/role/create"><span class="icon j_icon"></span>新增角色</a></div>
	</shiro:hasPermission>
	
	<!-- 内容 -->
	<div class="com_table">
		<table width="100%" cellpadding="0" cellspacing="0">
			<tr>
				<th>序号</th>
				<th>编号</th>
				<th>角色名</th>
				<th>备注</th>
				<th>拥有资源</th>
				<th>状态</th>
				<th>创建时间</th>
				<%--<th>创建人</th>
				<th>最后修改时间</th>
				<th>最后修改人</th>--%>
				<th>操作</th>
			</tr>
			<c:forEach items="${result.entityList}" var="role" varStatus="status">
			<tr>
				<td>${(result.currentPage-1)*result.pageSize+status.count}</td>
				<td>${role.rolId}</td>
				<td>${role.rolName}</td>
                <td>
                	<div class="utilTips">
						${role.rolDesc.length()>10?role.rolDesc.substring(0,10).concat(" ..."):role.rolDesc}
						<c:if test="${role.rolDesc.length()>10}">
						<div class="utilTipsText" style="display: none;">${role.rolDesc}</div>
						</c:if>
					</div>
                </td>
				<td>
                	<div class="utilTips">
						${role.resourceNames.length()>15?role.resourceNames.substring(0,15).concat(" ..."):role.resourceNames}
						<c:if test="${role.resourceNames.length()>15}">
                		<div class="utilTipsText" style="display: none;">${role.resourceNames}</div>
                		</c:if>
					</div>
				</td>
				<td>${diy:keyToValue(role.normal,'NORMAL')}</td>
				<td>
					<div class="utilTips">
						<pretty:prettyTime date="${role.insertDate}"/>
                		<div class="utilTipsText" style="display: none;"><fmt:formatDate value="${role.insertDate}" pattern="yyyy-MM-dd HH:mm:ss" /></div>
					</div>
				</td>
				<%--<td>${role.insertName }</td>
				<td><fmt:formatDate value="${role.lastUpdateDate}" pattern="yyyy-MM-dd" /></td>
				<td>${role.lastUpdateName }</td>--%>
				<td>
					<shiro:hasPermission name="users:role:view">
						<a class="icon micon_9" title="详情" href="${ctx}/role/${role.rolId}/detail"></a>
					</shiro:hasPermission>
                    <shiro:hasPermission name="users:role:update">
                       <a class="icon micon_2" title="编辑" href="${ctx}/role/${role.rolId}/update"></a>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="users:role:start/stop">
					<c:if test="${role.normal == 1}">
                    <a class="icon micon_1" title="停用" href="javascript:void(0);" onclick="doEnableOrDisable('${role.rolId}',${role.normal},'${role.rolName}')"></a>
                    </c:if>
                    <c:if test="${role.normal == 0}">
                    <a class="icon micon_12" title="启用" href="javascript:void(0);" onclick="doEnableOrDisable('${role.rolId}',${role.normal},'${role.rolName}')"></a>
                    </c:if>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="users:role:delete">
                       <a class="icon micon_20" title="删除" href="javascript:void(0);" onclick="del('${role.rolId}','${role.rolName }');" ></a>
                    </shiro:hasPermission>
					
				</td>
			</tr>
			</c:forEach>
		</table>
		
		<%-- 分页 --%>
		<%@ include file="/WEB-INF/common/page.jsp"%>
		
	</div>
</div>
</form>
</section>
</body>
</html>

